﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
       "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body>

<?php

ini_set( 'display_errors', false );

include("inc/joomlaInt.php");
include("inc/inc_configuration.php");

if ($jUser==0)
{
	echo "Bitte zuerst einloggen!";
}
else
{


	echo "<h1>Letzte Spiele</h1><table id='tborder' bgcolor='#DADADA'><thead id='tabelle'><tr><center><th colspan='10'>";

	echo "</center></th></tr></thead>";

	$q="	SELECT
				*
			FROM
				$tbl_matches m
			WHERE
				m.free=3
			ORDER BY 
				confDate DESC
			LIMIT 0,30";
	
	
	$qe=mysql_query($q);

	while ($row = mysql_fetch_object($qe))
	{
		$mI=$row->id;
		$homeT=$row->homeT;
		$guestT=$row->guestT;
		$hG=$row->homeG;
		$gG=$row->guestG;
		$f=$row->free;
		$hC=$row->homeC;
		$gC=$row->guestC;
		$liga=$row->leagueId;
		$playdate=$row->playDate;
		
		
		$datum=date("d.m.y <br> H:i",$playdate);
		
		$lpq="SELECT lp.path AS path FROM $tbl_leagues l, $tbl_leaguepics lp WHERE l.id=$liga AND l.picId=lp.id";
		$lpqe=mysql_query($lpq);
		$lpqeo=mysql_fetch_object($lpqe);
		$path=$lpqeo->path;

		
		$b="<a href='spielbericht.php?matchID=$mI&type=2'><img src='img/bericht.png' alt='Spielbericht'></a>";
		
		if ($hG=="")
		{
			$hG="-";
			$gG="-";
			$b="";
		}
		
		
		
		$tHq="SELECT name FROM $tbl_teams t WHERE t.id=$homeT";
		$tGq="SELECT name FROM $tbl_teams t WHERE t.id=$guestT";
		$tHqe = mysql_query($tHq);
		$tGqe = mysql_query($tGq);
		$tHn = mysql_fetch_object($tHqe)->name;
		$tGn = mysql_fetch_object($tGqe)->name;
		
		
		$uHSql="	SELECT u.username AS uHn, c.id AS hC, u.id AS uHi FROM $tbl_combinations c, $tbl_users u
					WHERE
					(c.id=$hC) AND c.userId=u.id";
		$uGSql="	SELECT u.username AS uGn, c.id AS gC, u.id AS uGi FROM $tbl_combinations c, $tbl_users u
					WHERE
					(c.id=$gC) AND c.userId=u.id";
		
		$uHq = mysql_query($uHSql);
		$uGq = mysql_query($uGSql);
		
		$uHo = mysql_fetch_object($uHq);
		$uGo = mysql_fetch_object($uGq);
		
		$uHn = $uHo->uHn;
		$uGn = $uGo->uGn;
		
		
		
		if ($uHn=="")
		{
			$uHn = "(-)";
		}
		
		if ($uGn=="")
		{
			$uGn = "(-)";
		}
		
		$uHi=$uHo->uHi;
		$uGi=$uGo->uGi;
		

			
		echo"<tr>	<td><img src='$leaguelogo_s_path",$path,"' width='50' height='50' alt='Kein Foto!'></td>
					<td width='42%'><center><a href='spiele_team.php?team=$homeT&liga=$liga'>$tHn</a>
									<br>
									<a href='profil.php?id=$uHi'>$uHn</a></td>
					<td><a href='team_kader.php?team=$homeT'><img src='img/logos/",$row->homeT,".png' width='35' height='35' alt=''></a></td>
					<td width='3%'><center>$hG</center></td>
					<td width='2%'><center>:</center></td>
					<td width='3%'><center>$gG</center></td>
					<td><a href='team_kader.php?team=$guestT'><img src='img/logos/",$row->guestT,".png' width='35' height='35' alt=''></a></td>
					<td width='42%'><center><a href='spiele_team.php?team=$guestT&liga=$liga'>$tGn
									<br>
									<a href='profil.php?id=$uGi'>$uGn</center></td>
					<td width='4%'><center>$datum</center></td>
					<td width='4%'><center>$b</center></td>
			</tr>";
	}

		echo "	<thead id='tabelle'><tr>
						<th></th>
						<th></th>
						<th></th>
						<th></th>
						<th></th>
						<th></th>
						<th></th>
						<th></th>
						<th></th>
						<th></th>
					</tr>
			</thead>";

	echo "</table><br><br>";


	echo "<br><br>
				<center><a href='lima.php' class='button zurueck'>Zurück</a></center>";

}
?>

</body>
</html>